package com.maxd.controller.selfCoupon;

import com.maxd.error.Result;
import com.maxd.model.SelfCouponUser;
import com.maxd.service.selfCoupon.SelfCouponUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value="自营商城优惠券领取",tags={"自营商城优惠券领取"})
@RequestMapping(value = "/selfCouponUser")
public class SelfCouponUserController {
    @Autowired
    private SelfCouponUserService service;

    @GetMapping("/list")
    @ApiOperation("列表")
    public Result findAll(Integer page, Integer size, String couponName, @ApiParam("店铺Id")@RequestParam(required = false) Long storeId) {
        return service.findAll(page, size, couponName, storeId);
    }

    @GetMapping("/userList")
    @ApiOperation("用户端用户优惠券列表")
    public Result userList(Integer page, Integer size, Long userId,@RequestParam(required = false) String goodsId, Integer type) {
        return service.userList(page, size, userId, goodsId, type);
    }

    @GetMapping("/useList")
    @ApiOperation("优惠券使用列表")
    public Result useList(Long userId,@RequestParam(required = false) String goodsId) {
        return service.useList(userId, goodsId);
    }

    @GetMapping("/find")
    @ApiOperation("查询")
    public Result findOne(Long id) {
        return service.findOne(id);
    }

    @PostMapping("/save")
    @ApiOperation("添加")
    public Result saveBody(@RequestBody SelfCouponUser entity) {
        return service.saveBody(entity);
    }

    @PostMapping("/update")
    @ApiOperation("修改")
    public Result updateBody(@RequestBody SelfCouponUser entity) {
        return service.updateBody(entity);
    }

    @GetMapping("/delete")
    @ApiOperation("删除")
    public Result delete(Long id) {
        return service.delete(id);
    }

}
